﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Shuba.Business;
using Shuba.Model;

namespace Shuba.Web
{
    public partial class logout : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Cache.SetNoStore();
            
            FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
            FormsAuthenticationTicket ticket = id.Ticket;

            User user = new User();
            UserInfo info = user.Get(HttpContext.Current.User.Identity.Name, ConfigurationManager.AppSettings["app.code"]);
            info.IsLogin = false;
            user.Update(info);

            TransactionLog log = new TransactionLog();
            log.Add(new TransactionLogInfo(basePage.ProcessingDate(), HttpContext.Current.User.Identity.Name, "LOGOUT", "Logout From Application, User Name : " + HttpContext.Current.User.Identity.Name));

            FormsAuthentication.SignOut();

            Session.Clear();
            Session.Abandon();
            
            Response.Redirect("~/default.aspx");
        }
    }
}
